<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
<link rel="stylesheet" href="css/login.css" />
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script src="js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
	<div class="login">
		<div style="text-align: center; margin-top: 138px; line-height: 35px;"
			class="row">
			<input type="text" id="username" placeholder="您的用户名" />
			</p>
			<input type="password" id="password" placeholder="您的密码" />
			</p>
			<button type="button" class="btn btn-primary" onclick="submit()">登陆</button>
			&nbsp;
			<button type="button" class="btn btn-primary">注册</button>
		</div>
	</div>
</body>
<script type="text/javascript">
	function submit() {
		var username = $("#username").val();
		var password = $("#password").val();
		if (username == null || username == "") {
			alert("请填写用户名");
			return;
		}
		if (password == null || password == "") {
			alert("请填写密码");
			return;
		}
		var user = {
			"username" : username,
			"password" : password
		};
		$.ajax({
			type : "post",
			url : "/login",
			async : true,
			contentType : "application/json",
			data : JSON.stringify(user),
			success : function(data) {
				if (data.msg != null) {
					alert(data.msg);
					return;
				}
				window.location.replace(data.path);
			}
		});
	}
</script>

</html>